Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(useChains): fix missing endpoints & chain name crash #534

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ArefEghbaliDev
Copy link

🛠 Fix: useChains Hook Issues

This PR fixes two issues related to the useChains hook in CosmosKit:

  1. Community Chains RPC/REST Error

    • Fixed an issue where using useChains with community chains would throw an error due to missing RPC or REST API endpoints in chainRecords.preferredEndpoints.
    • This bug does not occur when running tests but happens when running the example-lite project.
    • Affected chains: 'ethereum', 'rootstock', 'solana', 'ton', 'tron', 'bluechip', 'lorenzo', 'neura', 'paloma', 'unicorn'.
  2. Crash When Using Chain Names in ChainProvider 🔗 Fixes: Uncaught TypeError: Cannot read properties of undefined (reading 'chain_id') when using useChains #515

    • Fixed an issue where passing only chain names (instead of full chain info) to ChainProvider caused a crash.
    • This was due to convertChain returning undefined when receiving a chain name instead of a chain object, resulting in an empty chain in chainRecord.
    • This fix ensures proper handling of chain names, preventing the crash.

@mehrdadpfg
Copy link

cc: @pyramation

@@ -1,4 +1,5 @@
import { AssetList, Chain } from '@chain-registry/types';
import { chains } from 'chain-registry';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry — we shouldn't be loading in the full blown chain-registry like this, is is already doing that or is this new?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, loading chains from chain-registry is new here. The reason for this change is that the bug being fixed occurs when a user passes only chain names to the chain provider instead of the full chains object from chain-registry. As a result, this file doesn’t have the necessary chain data. To resolve this, I loaded chain-registry to retrieve the chain data.

If you have any suggestions for improvement or know of alternative ways to fix this, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants